package com.cgwx.controller;

import com.alibaba.fastjson.JSONObject;
import com.cgwx.common.utils.PageUtil;
import com.alibaba.fastjson.JSON;
import com.cgwx.Utils.result.ResultUtil;
import com.cgwx.aop.GetUserInfo;
import com.cgwx.config.BusinessException;
import com.cgwx.config.SuppressResponseLog;
import com.cgwx.data.dto.*;
import com.cgwx.entity.*;
import com.cgwx.mapper.*;
import com.cgwx.service.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.*;

@RestController
@Api(tags = "外部")
@RequestMapping("/company")
@Slf4j
public class OuterController {
    @Resource
    private IFolderService folderService;
    @Resource
    private IUtilService utilService;
    @Resource
    private FileMapper fileMapper;
    @Resource
    private DeptMapper deptMapper;
    @Resource
    private RoomMapper roomMapper;
    @Resource
    private IAuthorityService authorityService;
    @Resource
    private ISharedService sharedService;
    @Value("${nonPj}")
    private String nonPj;
    @Resource
    private AuthorityMapper authorityMapper;
    @Resource
    private IFsTransmitRecordService fsTransmitRecordService;
    @Resource
    private IFsTransmitDetailService fsTransmitDetailService;
    @Resource
    private UserMapper userMapper;

    @GetMapping("/updateFile")
    @ApiOperation("多版本文件更新(后台调用)")
    public Object uploadVersionFile(@RequestParam String ownerAccount, @RequestParam String ownerName, @RequestParam String entityName, @RequestParam String fileId, @RequestParam String fileUrl, @RequestParam String entityId, @RequestParam String versionId) {
        return utilService.updateFile(ownerAccount, ownerName, entityName, fileId, fileUrl, entityId, versionId);
    }

    @GetMapping("/getVersionFile")
    @GetUserInfo
    @ApiOperation("文件历史版本查询")
    public Object getVersionFile(UserInfo userInfo, @RequestParam String fileId) {
        List<MinioFileVersion> result = utilService.getVersionFile(fileId);
        return ResultUtil.success(result);
    }

    @GetMapping("/insertNonProject")
    @ApiOperation("非项目编审批上传(后台调用)")
    public Object insertNonProject(@RequestParam String userId, @RequestParam String userName, @RequestParam String parentId, @RequestParam String fileUrl, @RequestParam String fileId, @RequestParam String fileName, @RequestParam String managerUserId, @RequestParam String managerUserName) {
        Folder folder = new Folder();
        folder.setEntityId(parentId);
        String roomId = folderService.getFolder(folder).get(0).getEntityRoom();
        return utilService.insertNonProject(userId, userName, roomId, parentId, fileUrl, fileId, fileName, managerUserId, managerUserName);
    }

    @GetMapping("/getFolderStr")
    @ApiOperation("获取文件夹结构(后台调用)")
    public Object getFolderStr(@RequestParam String entityId) {
        Folder folder = new Folder();
        folder.setEntityId(entityId);
        folder = folderService.getFolder(folder).get(0);
        List<UsDept> depts = deptMapper.getAllDept();
        List<String> deptNames = new ArrayList<>();
        for (UsDept dept : depts) deptNames.add(dept.getOrganizationName());
        //部门那层
        String outer;
        String inner;
        String parentId;
        //大类
        if(deptNames.contains(folder.getEntityName())){
            parentId = folder.getParentId();
            folder = new Folder();
            folder.setEntityId(parentId);
            folder = folderService.getFolder(folder).get(0);//小类
        }
        inner = folder.getEntityName();
        parentId = folder.getParentId();
        folder = new Folder();
        folder.setEntityId(parentId);
        folder = folderService.getFolder(folder).get(0);//大类
        outer = folder.getEntityName();
        return outer + "@#" + inner;
    }

    @GetMapping("/openNonPjFolder")
    @GetUserInfo
    @ApiOperation("打开签批文件夹")
    public Object openNonPjFolder(UserInfo userInfo, @RequestParam String entityId, String keyword, String column, String sort, @RequestParam int pageNum, @RequestParam int pageSize) {
        // 鉴权
        Map<String, String> map1 = new HashMap<>();
        Map<String, String> map2 = new HashMap<>();
        List<FileFolder> fileFolders;
        FileFolder fileFolder = new FileFolder();
        fileFolder.setParentId(entityId);
        if(userInfo.getDeptId().equals("000100")){
            fileFolders = fileMapper.getFileFolder(fileFolder);
            int index = 1;
            for(FileFolder fileFolder1 : fileFolders){
                map1.put(String.valueOf(index), fileFolder1.getEntityId());
                index++;
            }
            //具备管理权限的
            index = 1;
            for(FileFolder fileFolder1 : fileFolders){
                map2.put(String.valueOf(index), fileFolder1.getEntityId());
                index++;
            }
        }
        else{
            //permission_id员工和部门的
            fileFolder.setOwnerAccount(userInfo.getUserId());
            fileFolder.setEntityRoom(userInfo.getDeptId());
            fileFolders = fileMapper.getAuthorityFileFolder(fileFolder);
            int index = 1;
            for(FileFolder fileFolder1 : fileFolders){
                map1.put(String.valueOf(index), fileFolder1.getEntityId());
                index++;
            }
            //具备管理权限的
            index = 1;
            for(FileFolder fileFolder1 : fileFolders){
                if(authorityService.checkAuthority(userInfo.getUserId(), userInfo.getDeptId(), fileFolder1.getEntityId()).equals("4")) map2.put(String.valueOf(index), fileFolder1.getEntityId());
                index++;
            }
        }
        //关键词
        map1.put("keyword", keyword);
        map2.put("keyword", keyword);
        map1.put("userId", userInfo.getUserId());
        map2.put("userId", userInfo.getUserId());
        log.info("map1: {}", map1);
        log.info("map2: {}", map2);
        String level = authorityService.checkAuthority(userInfo.getUserId(), userInfo.getDeptId(), entityId);
        if(!fileFolders.isEmpty()){
            String result;
            if(fileFolders.get(0).getEntityRoom().equals("0")) {
                List<NpjManageDto> npjManageDtoList = new ArrayList<>();
                //启用
                result = utilService.getMethod(nonPj + "/nonPj/getManageFileByEntityId", map1);
                log.info("启用的管理: {}", result);
                if(result != null && !result.isEmpty()) npjManageDtoList.addAll(JSON.parseArray(result, NpjManageDto.class));
                //停用
                result = utilService.getMethod(nonPj + "/nonPj/getStopManageFileByEntityId", map2);
                log.info("停用的管理: {}", result);
                if(result != null && !result.isEmpty()) npjManageDtoList.addAll(JSON.parseArray(result, NpjManageDto.class));
                if(column != null && sort != null) npjManageDtoList = utilService.sortNpjManageDto(npjManageDtoList, column, sort);
                PageUtil<NpjManageDto> page = new PageUtil<NpjManageDto>().getPage(npjManageDtoList.size(), pageSize, pageNum - 1);
                page.setList(page.startPage(npjManageDtoList.size(), pageNum, pageSize, npjManageDtoList));
                return ResultUtil.success(page, level);
            }
            else{
                Folder folder = new Folder();
                folder.setEntityId(entityId);
                folder = folderService.getFolder(folder).get(0);
                if(folder.getEntityName().contains("图册")){
                    List<NpjAtlasDto> npjAtlasDtoList = new ArrayList<>();
                    //启用
                    result = utilService.getMethod(nonPj + "/nonPj/getAtlasFileByEntityId", map1);
                    //System.out.println("启用的: " + result);
                    log.info("启用的图册: {}", result);
                    if(result != null && !result.isEmpty()) npjAtlasDtoList.addAll(JSON.parseArray(result, NpjAtlasDto.class));
                    //停用
                    result = utilService.getMethod(nonPj + "/nonPj/getStopAtlasFileByEntityId", map2);
                    //System.out.println("停用的: " + result);
                    log.info("停用的图册: {}", result);
                    if(result != null && !result.isEmpty()) npjAtlasDtoList.addAll(JSON.parseArray(result, NpjAtlasDto.class));
                    if(column != null && sort != null) npjAtlasDtoList = utilService.sortNpjAtlasDto(npjAtlasDtoList, column, sort);
                    PageUtil<NpjAtlasDto> page = new PageUtil<NpjAtlasDto>().getPage(npjAtlasDtoList.size(), pageSize, pageNum - 1);
                    page.setList(page.startPage(npjAtlasDtoList.size(), pageNum, pageSize, npjAtlasDtoList));
                    return ResultUtil.success(page, level);
                }
                else{
                    List<NpjReportDto> npjReportDtoList = new ArrayList<>();
                    //启用
                    result = utilService.getMethod(nonPj + "/nonPj/getReportFileByEntityId", map1);
                    //System.out.println("启用的: " + result);
                    log.info("启用的报告: {}", result);
                    if(result != null && !result.isEmpty()) npjReportDtoList.addAll(JSON.parseArray(result, NpjReportDto.class));
                    //停用
                    result = utilService.getMethod(nonPj + "/nonPj/getStopReportFileByEntityId", map2);
                    //System.out.println("停用的: " + result);
                    log.info("停用的报告: {}", result);
                    if(result != null && !result.isEmpty()) npjReportDtoList.addAll(JSON.parseArray(result, NpjReportDto.class));
                    if(column != null && sort != null) npjReportDtoList = utilService.sortNpjReportDto(npjReportDtoList, column, sort);
                    PageUtil<NpjReportDto> page = new PageUtil<NpjReportDto>().getPage(npjReportDtoList.size(), pageSize, pageNum - 1);
                    page.setList(page.startPage(npjReportDtoList.size(), pageNum, pageSize, npjReportDtoList));
                    return ResultUtil.success(page, level);
                }
            }
        }
        return ResultUtil.success(fileFolders, level);
    }

    @GetMapping("/invalid")
    @GetUserInfo
    @ApiOperation("停用文件")
    public Object invalid(UserInfo userInfo, @RequestParam String id, @RequestParam String entityId, @RequestParam String type) {
        String authorityStr = authorityService.checkAuthority(userInfo.getUserId(), userInfo.getDeptId(), entityId);
        if(!authorityStr.equals("4")) ResultUtil.success("您没有管理权限!");
        Map<String, String> map = new HashMap<>();
        map.put("id", id);
        map.put("type", type);
        String result = utilService.getMethod(nonPj + "/nonPj/invalid", map);
        if(result.equals("false")) return ResultUtil.error(200, "false");
        else return ResultUtil.success(result);
    }

    @GetMapping("/valid")
    @GetUserInfo
    @ApiOperation("启用文件")
    public Object valid(UserInfo userInfo, @RequestParam String id, @RequestParam String entityId, @RequestParam String type) {
        String authorityStr = authorityService.checkAuthority(userInfo.getUserId(), userInfo.getDeptId(), entityId);
        if(!authorityStr.equals("4")) ResultUtil.success("您没有管理权限!");
        Map<String, String> map = new HashMap<>();
        map.put("id", id);
        map.put("type", type);
        String result = utilService.getMethod(nonPj + "/nonPj/valid", map);
        if(result.equals("false")) return ResultUtil.error(200, "false");
        else return ResultUtil.success(result);
    }

    @GetMapping("/qianpiRename")
    @GetUserInfo
    @Transactional
    @ApiOperation("签批文件夹改名(后台数据初始化)")
    public Object qianpiRename() {
        List<UsDept> depts = deptMapper.getAllDept();
        for(UsDept dept: depts) {
            Room room = new Room();
            room.setRoomType("dept");
            room.setRoomName(dept.getOrganizationName());
            room = roomMapper.getRoom(room).get(0);
            Folder folder = new Folder();
            folder.setEntityName("签批文件");
            folder.setEntityRoom(room.getId());
            List<Folder> folderFinds = folderService.getFolder(folder);
            if (folderFinds.isEmpty()) {
                log.error("qianpiRename: {}签批文件不存在!", dept.getOrganizationId());
                throw new BusinessException(dept.getOrganizationId() + "签批文件不存在!");
            }
            if (folderFinds.size() > 1) {
                log.error("qianpiRename: {}签批文件不唯一!", dept.getOrganizationId());
                throw new BusinessException(dept.getOrganizationId() + "签批文件不唯一!");
            }
            folder = folderFinds.get(0);
            folder.setEntityName(dept.getOrganizationName() + "签批文件");
        }
        return ResultUtil.success("签批文件夹改名成功!");
    }

    @GetMapping("/getDeptShared")
    @GetUserInfo
    @SuppressResponseLog
    @ApiOperation("获取部门签批文件分享")
    public Object getDeptShared(UserInfo userInfo, String keyword, @RequestParam int pageNum, @RequestParam int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Shared> result = sharedService.getDeptShared(userInfo.getUserId(), keyword);
        return ResultUtil.success(new PageInfo<>(result));
    }

    @GetMapping("/checkAuthorityOuter")
    @GetUserInfo
    @SuppressResponseLog
    @ApiOperation("获取员工的单个文件（夹）权限(后台调用)")
    public Object checkAuthorityOuter(@RequestParam String entityId, @RequestParam String userId, @RequestParam String deptId) {
        return authorityService.checkAuthority(userId, deptId, entityId);
    }

    @GetMapping("/sendPost")
    @SuppressResponseLog
    @ApiOperation("发送Post")
    public Object sendPost(@RequestParam String path, @RequestParam String fileIds, @RequestParam String clusterId) {
        try {
            HttpClient httpClient = new HttpClient();
            httpClient.getParams().setContentCharset("UTF-8");
            //PostMethod postMethod = new PostMethod("http://10.249.39.165:8010/file/mergeFileUploadByIds");
            PostMethod postMethod = new PostMethod("http://10.254.135.10:8079/file/mergeFileUploadByIds");
            postMethod.setParameter("bucketName", "xgb-store");
            postMethod.setParameter("sysSource", "PermanentAuth");
            postMethod.setParameter("clusterId", clusterId);
            postMethod.setParameter("path", path);//0446/2024/11/06/173532
            postMethod.setParameter("fileIds", fileIds);//241106174400000qyQbB
            postMethod.setParameter("userId", "0772");
            postMethod.setParameter("deptId", "000306");
            postMethod.setParameter("roleId", "EMPLOYEE");
            httpClient.executeMethod(postMethod);
            String result = postMethod.getResponseBodyAsString();
            JSONObject jsonObject = JSON.parseObject(result);
            log.info("返回结果为: {}", jsonObject.toJSONString());
            return ResultUtil.success(jsonObject);
        } catch (Exception var10) {
            return null;
        }
    }

    @GetMapping("/addAuth")
    @GetUserInfo
    @SuppressResponseLog
    @ApiOperation("给某个员工/部门/公司新增签批文件权限(后台调用)")
    public Object addAuth(@RequestParam String entityId, @RequestParam String permissionType, @RequestParam String permissionId, @RequestParam String permissionName, @RequestParam String level) {
        Authority authority = new Authority();
        authority.setEntityId(entityId);
        authority.setEntityName(utilService.getEntityNameByEntityId(entityId));
        authority.setPermissionType(permissionType);
        authority.setPermissionId(permissionId);
        authority.setPermissionName(permissionName);
        authority.setAuthorityLevel(level);
        authority.setFileOrFolder("file");
        authority.setId(UUID.randomUUID().toString());
        Timestamp time = Timestamp.valueOf(LocalDateTime.now());
        authority.setCreateTime(time);
        authority.setUpdateTime(time);
        return authorityMapper.insertAuthority(authority);
    }

    @RequestMapping("/insertTransmitTask")
    @ApiOperation("新增文件传输记录/详情")
    @Transactional
    public Object insertTransmitTask(@RequestParam String account, @RequestParam String totalNum, @RequestParam String savePath, @RequestParam String jsonString) {
        if(!fsTransmitRecordService.insertFsTransmitRecord(account, totalNum, savePath)){
            log.warn("新增文件传输记录失败{}: {}", savePath, jsonString);
            throw new BusinessException("新增文件传输记录失败!" + savePath + ": " + jsonString);
        }
        FsTransmitRecord fsTransmitRecord = new FsTransmitRecord();
        fsTransmitRecord.setSavePath(savePath);
        List<FsTransmitRecord> FsTransmitRecords = fsTransmitRecordService.getFsTransmitRecord(fsTransmitRecord);
        if(FsTransmitRecords == null || FsTransmitRecords.isEmpty()){
            log.warn("insertTransmitTask文件传输记录不存在!{}", savePath);
            throw new BusinessException("文件传输记录不存在!" + savePath);
        } else if (FsTransmitRecords.size() > 1) {
            log.warn("insertTransmitTask文件传输记录不唯一!{}", savePath);
            throw new BusinessException("文件传输记录不唯一!" + savePath);
        }
        if(!fsTransmitDetailService.insertFsTransmitDetail(FsTransmitRecords.get(0), jsonString)){
            log.warn("insertTransmitTask新增新增文件传输详情失败{}: {}", savePath, jsonString);
            throw new BusinessException("insertTransmitTask新增新增文件传输详情失败!" + savePath + ": " + jsonString);
        }
        return ResultUtil.success("新增成功!");
    }

    @GetMapping("/updateTransmitTask")
    @ApiOperation("修改文件传输状态")
    @Transactional
    public Object updateTransmitTask(@RequestParam String jsonString) {
        JSONObject jsonObject = JSONObject.parseObject(jsonString);
        String path = jsonObject.getString("path");
        Map<String, String> map = utilService.jsonObjectToStringMap(jsonObject);
        map.remove("path");
        FsTransmitRecord fsTransmitRecord = new FsTransmitRecord();
        fsTransmitRecord.setSavePath(path);
        fsTransmitRecord = fsTransmitRecordService.getFsTransmitRecord(fsTransmitRecord).get(0);
        if(!fsTransmitDetailService.updateFsTransmitDetail(fsTransmitRecord.getId(), map)){
            log.warn("updateTransmitTask文件传输记详情修改失败!{}", path);
            throw new BusinessException("updateTransmitTask文件传输记详情修改失败!" + path);
        }
        return ResultUtil.success("文件传输详情修改成功!");
    }

    @GetMapping("/completeTransmitTask")
    @ApiOperation("文件传输完成")
    @Transactional
    public Object completeTransmitTask(@RequestParam String jsonString) {
        JSONObject jsonObject = JSONObject.parseObject(jsonString);
        String path = jsonObject.getString("path");
        Map<String, String> map = utilService.jsonObjectToStringMap(jsonObject);
        map.remove("path");
        LocalDateTime time = Timestamp.valueOf(LocalDateTime.now()).toLocalDateTime();
        if(!fsTransmitRecordService.updateFsTransmitRecord(path, map, time)){
            log.warn("completeTransmitTask文件传输记录修改失败!{}", path);
            throw new BusinessException("completeTransmitTask文件传输记录修改失败!" + path);
        }
        FsTransmitRecord fsTransmitRecord = new FsTransmitRecord();
        fsTransmitRecord.setSavePath(path);
        fsTransmitRecord = fsTransmitRecordService.getFsTransmitRecord(fsTransmitRecord).get(0);
        if(!fsTransmitDetailService.completeFsTransmitDetail(fsTransmitRecord.getId(), map, time, path)){
            log.warn("completeTransmitTask文件传输记详情修改失败!{}", path);
            throw new BusinessException("completeTransmitTask文件传输记详情修改失败!" + path);
        }
        return ResultUtil.success("文件传输完成!");
    }

    @GetMapping("/getTransmitTask")
    @ApiOperation("获取文件传输记录")
    @Transactional
    @GetUserInfo
    public Object getTransmitTask(UserInfo userInfo, String keyword, @RequestParam int pageNum, @RequestParam int pageSize, String column, String sort) {
        PageHelper.startPage(pageNum, pageSize);
        FsTransmitRecord fsTransmitRecord = new FsTransmitRecord();
        fsTransmitRecord.setOwnerAccount(userInfo.getUserId());
        fsTransmitRecord.setTaskName(keyword);
        return ResultUtil.success(new PageInfo<>(fsTransmitRecordService.getFsTransmitRecord(fsTransmitRecord, column, sort)));
    }

    @GetMapping("/getTransmitDetail")
    @ApiOperation("获取文件传输详情")
    @Transactional
    @GetUserInfo
    public Object getTransmitDetail(UserInfo userInfo, @RequestParam String taskId, String keyword, String status, @RequestParam int pageNum, @RequestParam int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        FsTransmitDetail fsTransmitDetail = new FsTransmitDetail();
        fsTransmitDetail.setTaskId(taskId);
        fsTransmitDetail.setFileName(keyword);
        fsTransmitDetail.setStatus(status);
        return ResultUtil.success(new PageInfo<>(fsTransmitDetailService.getFsTransmitDetail(fsTransmitDetail)));
    }

    @PostMapping("/uploadFileNoAuth")
    @ApiOperation("上传文件(无用户信息)")
    public Object uploadFile(@RequestParam String savePath, @RequestParam String userId, @RequestParam MultipartFile multipartFile) {
        UsUser user = new UsUser();
        user.setAccount(userId);
        user = userMapper.getUser(user).get(0);
        FsTransmitRecord fsTransmitRecord = new FsTransmitRecord();
        fsTransmitRecord.setSavePath(savePath);
        List<FsTransmitRecord> fsTransmitRecordList = fsTransmitRecordService.getFsTransmitRecord(fsTransmitRecord);
        if(fsTransmitRecordList == null || fsTransmitRecordList.isEmpty()){
            log.warn("uploadFileNoAuth文件传输文件夹不存在!{}", savePath);
            throw new BusinessException("uploadFileNoAuth文件传输文件夹不存在!" + savePath);
        }
        else if(fsTransmitRecordList.size() > 1){
            log.warn("uploadFileNoAuth文件传输文件夹不唯一!{}", savePath);
            throw new BusinessException("uploadFileNoAuth文件传输文件夹不唯一!" + savePath);
        }
        Folder folder = new Folder();
        folder.setEntityId(fsTransmitRecordList.get(0).getParentId());
        String roomId = folderService.getFolder(folder).get(0).getEntityRoom();
        String result = utilService.uploadFile(userId, user.getName(), user.getDeptId(), roomId, fsTransmitRecordList.get(0).getParentId(), "staff", multipartFile, "true");
        return ResultUtil.success(result);
    }

    @GetMapping("/getAllPersonalFiles")
    @ApiOperation("获取个人空间所有文件")
    @Transactional
    @GetUserInfo
    public Object getAllPersonalFiles(UserInfo userInfo, String fileName, @RequestParam int pageNum, @RequestParam int pageSize) {
        Room room = new Room();
        room.setRoomId(userInfo.getUserId());
        room.setRoomType("staff");
        List<Room> roomList = roomMapper.getRoom(room);
        if(roomList == null || roomList.isEmpty()) return ResultUtil.error(200, "该用户不存在个人空间!");
        else if(roomList.size() > 1) return ResultUtil.error(200, "该用户个人空间不唯一!");
        room = roomList.get(0);
        File file = new File();
        file.setEntityName(fileName);
        file.setEntityRoom(room.getId());
        PageHelper.startPage(pageNum, pageSize);
        return ResultUtil.success(new PageInfo<>(fileMapper.getAllPersonalFiles(file)));
    }

    @GetMapping("/createFolder")
    @ApiOperation("公司空间新建文件夹")
    @Transactional
    public Object createFolder(@RequestParam String fileName, @RequestParam String path, String createrId) {
        Room room = new Room();
        room.setRoomType("company");
        List<Room> roomList = roomMapper.getRoom(room);
        room = roomList.get(0);
        String parentId = utilService.getEntityIdByPath(room.getId(), path);
        String name = null;
        if(createrId != null && !createrId.isEmpty()){
            UsUser user = new UsUser();
            user.setAccount(createrId);
            user = userMapper.getUser(user).get(0);
            name = user.getName();
        }
        if(!folderService.createFolder(createrId, name, room.getId(), fileName, parentId).equals("新增成功!")){
            log.warn("createFolder: 文件夹创建失败!");
            return ResultUtil.error(200, "文件夹创建失败!");
        }
        return ResultUtil.success("文件夹创建成功!");
    }

    @GetMapping("/checkFolder")
    @ApiOperation("查看文件夹")
    @Transactional
    public Object checkFolder(@RequestParam String path) {
        Room room = new Room();
        room.setRoomType("company");
        List<Room> roomList = roomMapper.getRoom(room);
        room = roomList.get(0);
        String entityId = utilService.getEntityIdByPath(room.getId(), path);
        if(entityId == null) return ResultUtil.error(200, "该路径不存在!");
        FileFolder fileFolder = new FileFolder();
        fileFolder.setParentId(entityId);
        List<FileFolder> fileFolders = fileMapper.getFileFolder(fileFolder);
        return ResultUtil.success(fileFolders);
    }
}